<?php

	class URL{
		
		public $id;		
		public $url;		
		public $subMenu;		
		public $obs;		
		public $principal;
		
		public function getId(){
			
			return $this->id;
			
		}
		
		public function setId($id){
			
			$this->id = $id;
			
		}
		
		public function setUrl($url){
			
			$this->url = $url;	
			
		}
		
		public function getUrl(){
			
			return $this->url;
			
		}
		
		public function setSubMenu($subMenu){
			
			$this->subMenu = $subMenu;
			
		}
		
		public function getSubMenu(){
			
			return $this->subMenu;
			
		}
		
		public function setObs($obs){
			
			$this->obs = $obs;
			
		}
		
		public function getObs(){
			
			return $this->obs;
			
		}
		
		public function setPrincipal($principal){
			
			$this->principal = $principal;
			
		}
		
		public function getPrincipal(){
			
			return $this->principal;
			
		}
		public function getUrlForId(){
			$db = new conexao();
			$db->abrir();
			$sql = "select * from `url` ur
					where ur.`sub_id`= ".$this->getId()."
					and  ur.`url_principal` = 1";
			$resp = $db->consulta($sql);
			if($linha = $db->get_linha($resp)){
				$this->setId($linha[""]);
				$this->setUrl($linha["url_desc"]);
			}
			
			$db->fechar();
			
		}
		public function inserir(){
			
			$db = new conexao();
			$db->abrir();
			
			$sql = "INSERT INTO `url` (`sub_id`, `url_desc`, `url_obs`, `url_principal`) VALUES 
	  				(".$this->getSubMenu()->getId().",'".$this->getUrl()."','".$this->getObs()."',".$this->getPrincipal().");";	
	  		
	  		if($db->inserir($sql)){
	  			
	  			$db->fechar();
	  			return  true;
	  			
	  		}
	  		
	  		else{
	  			
	  			$db->fechar();
	  			return false;
	  				
	  		}
	  					
	  	}
		
	}
	
?>
